package com.genntii.examManager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.genntii.examManager.domain.entity.QuestionBank;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface QuestionBankMapper extends BaseMapper<QuestionBank> {
//    @Select("select * from question_bank " +
//            "where subject_id = #{subjectId} " +
//            "and name like concat('*',#{keyword},'*') and type = #{type} " +
//            "limit #{pageNum},#{pageSize}")
    ArrayList<QuestionBank> getQuestionBankListBySubject(@Param("subjectId")Long subjectId,
                                                         @Param("pageNum") Integer pageNum,
                                                         @Param("pageSize")Integer pageSize,
                                                         @Param("keyword")String keyword,
                                                         @Param("type") Byte type);

//    @Select("select count(*) from question_bank where subject_id = #{subjectId} and type = 1")
    long getQuestionBankTotalBySubject(@Param("subjectId")Long subjectId,
                                       @Param("keyword")String keyword,
                                       @Param("type") Byte type);

}
